package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductUnusualFeedbackReplyConfirmView;
import com.cloudsigns.factorymanager2.produce.model.IProductUnusualFeedbackReplyConfirmModel;
import com.cloudsigns.factorymanager2.produce.model.ProductUnusualFeedbackReplyConfirmModel;

public class ProductUnusualFeedbackReplyConfirmPresenter {
    private IProductUnusualFeedbackReplyConfirmView view;
    private IProductUnusualFeedbackReplyConfirmModel model;
    private Handler handler = new Handler();

    public ProductUnusualFeedbackReplyConfirmPresenter(IProductUnusualFeedbackReplyConfirmView view) {
        this.view = view;
        this.model = new ProductUnusualFeedbackReplyConfirmModel();
    }

    public void productUnusualFeedbackReplyConfirm() {
        model.productUnusualFeedbackReplyConfirm(view.getOrderId(), view.getProductId(), view.getWorkPartFeedbackId(), view.getWorkPartId(), view.getWorkPartOrderId(), new ProductUnusualFeedbackReplyConfirmModel.OnProductUnusualFeedbackReplyConfirmListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductUnusualFeedbackReplyConfirmSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductUnusualFeedbackReplyConfirmFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
